<%@ page import="java.util.ArrayList" %>
<%@ page import="com.example.mystore.entity.Commodity" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>品优购</title>
    <link rel="stylesheet" href="css/header.css">
    <link rel="stylesheet" href="css/footer.css">
    <style>
        .banner{background-color:white;width: 1350px;height: 520px;margin: 0 auto;}
        .banner .nav{height:100%;width: 20%;overflow:scroll;}
        .banner .box{height:100%;width: 80%;overflow:scroll; }
        .banner .box .commodityBox{height: 120px;margin: 15px 110px;}
        .banner .box .commodityBox img{height: 100%;width:120px;margin: 5px 5px;}
        .banner .nav::-webkit-scrollbar {display:none}
        .banner .box::-webkit-scrollbar {display:none}
        .left{float: left;}
        .right{float: right;}
        li a:hover{color: white;}
        a{text-decoration: none;}
        li a{color:#333;width: 100%;display: block; padding: 20px 0}
        a button{border: 0;background-color:#fbb117;color: aliceblue;border-radius: 20px;}
        ol{padding: 0}
        li{list-style: none;width: 100%;text-align: center;}
        li:hover{background-image: radial-gradient(teal,royalblue);}

    </style>
</head>
<body>
<%if(request.getSession().getAttribute("categoryHM") == null) {
    response.sendRedirect(request.getContextPath()+"/Display");
}else {%>
    <header id="header">
        <div id="headerBox">
            <h1>品优购</h1>
            <a href="#">首页</a>
            <a href="Cart.jsp">我的购物车</a>
            <a href="">联系客服</a>
            <%if (request.getSession().getAttribute("customer")!=null){%>
            <a href="${pageContext.request.contextPath}/LogoutServlet" style="float: right;">退出登录</a>
            <%}else{%>
            <a href="login.jsp" style="float: right;">用户登录</a>
           <%}%>
            <hr>
        </div>
    </header>
<div class="banner">
    <div class="left nav">
        <h2 style="text-align: center">产品列表</h2>
        <nav>
            <ol>
                <%String path = request.getContextPath();
                    HashMap<Integer,String> categoryHM = (HashMap<Integer, String>) request.getSession().getAttribute("categoryHM");
                %>
                <% for(Map.Entry<Integer,String> entry : categoryHM.entrySet()){%>
                <li><a href="<%=path%>/Display?category=<%=entry.getKey()%>"><%=entry.getValue()%></a></li>
                <%}%>
            </ol>
        </nav>
    </div>
    <div class="right box">
        <%for(Commodity commodity : (ArrayList<Commodity>) request.getSession().getAttribute("commodityArr")){%>
        <div class="left commodityBox">
            <img src="img/<%=commodity.getImg()%>" alt="" class="left">
            <div class="left commodityD">
                <a href="details.jsp?id=<%=commodity.getId()%>"><div style="font-weight: bolder" ><%=commodity.getName()%></div></a>
                <div><b>型号：</b><%=commodity.getModel()%></div>
                <div><b>价格：￥</b><%=commodity.getPrice()%></div>
                <div>
                    <a href="${pageContext.request.contextPath}/toAdd?id=<%=commodity.getId()%>"><button>购买</button></a>
                    <a href="${pageContext.request.contextPath}/toAdd?id=<%=commodity.getId()%>"><button>加入购物车</button></a>
                </div>
            </div>
        </div>
        <%}%>
    </div>
</div>
<footer id="footer">
    <div id="footerBox">
        <div class="">
            <a  href="">
                关于我们
            </a>
            |
            <a href="">
                联系我们
            </a>
            |
            <a href="">
                人才招聘
            </a>
            |
            <a  href="">
                商家入驻
            </a>
            |
            <a href="">
                广告服务
            </a>
            |
            <a  href="">
                友情链接
            </a>
            |
            <a  href="">
                销售联盟
            </a>
            |
            <a href="" >
                商家社区
            </a>
            |
            <a href="" >
                捐款公益
            </a>
        </div>
        <div class="">
            1107841498@qqcom&nbsp;©&nbsp;&nbsp;&nbsp;&nbsp;版权归<a href="">@清秋</a>所有
        </div>
    </div>
   </footer>
<%}%>
</body>
</html>
